<template>
  <a-drawer
    title="异常信息"
    placement="right"
    width="80%"
    :visible="visible"
    :confirmLoading="confirmLoading"
    :destroyOnClose="true"
    @close="handleCancel"
  >
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="48">
          <a-col :md="8" :sm="8">
            <a-form-item label="学院">
              <a-input placeholder="请输入学院" v-model="queryParam.institute" />
            </a-form-item>
          </a-col>
          <a-col :md="8" :sm="8">
            <a-form-item label="专业班级">
              <a-input placeholder="请输入专业班级" v-model="queryParam.major" />
            </a-form-item>
          </a-col>
          <a-col :md="8" :sm="8">
            <a-form-item label="导员名称">
              <a-input placeholder="请输入导员名称" v-model="queryParam.assistantName" />
            </a-form-item>
          </a-col>
          <a-col :md="8" :sm="24">
            <a-button @click="() => {this.queryPage()}" type="primary">查询</a-button>
            <a-button @click="() =>{ queryParam = {}}" style="margin-left: 8px">重置</a-button>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <div class="table-operator">
      <!--  <a-button @click="(e) => this.goToUpload()" style="margin-bottom: 8px">
         导入
       </a-button> -->
    </div>
    <v-table
      :table-column="columns"
      :data="loadData"
      :rowKey="record => record.id"
      bordered
      ref="table"
      style="margin-top:8px"
    >
    </v-table>
    <Wfu-alarm-detail
      @ok="queryPage"
      ref="WfuAlarmDetail">
    </Wfu-alarm-detail>
  </a-card>
  </a-drawer>
</template>

<script>
import { TableMixin } from '@/mixins/TableMixin'
import { pageErrorAlarmList } from '@api/wfuAlarm/wfuAlarm'
import WfuAlarmDetail from '../wfuAlarm/WfuAlarmDetail'

export default {
  components: {
    WfuAlarmDetail
  },
  mixins: [TableMixin],
  name: 'alermDetails',
  data () {
    return {
      columns: [
        {
          title: '姓名',
          field: 'userName'
        },
        {
          title: '学号',
          field: 'userCode'
        },
        {
          title: '学院',
          field: 'institute'
        },
        {
          title: '专业班级',
          field: 'major'
        },
        {
          title: '学生电话',
          field: 'mobile'
        },
        {
          title: '导员姓名',
          field: 'assistantName'
        },
        {
          title: '导员工号',
          field: 'assistantCode'
        },
        {
          title: '导员电话',
          field: 'assistantMobile'
        },
        {
          title: '备注',
          field: 'remarks'
        },
        {
          title: '操作',
          width: '120px',
          customRender: (text, record, index) => {
            return (
              <div>
                <a onClick={(e) => this.show(record)}
                >查看详情</a>
              </div>
            )
          }
        }
      ],
      visible: false,
      confirmLoading: false,
      queryParam: {
        institute: '',
        major: '',
        assistantName: '',
        timeScope: ''
      },
      loadData: parameter => {
        return pageErrorAlarmList(
          Object.assign(parameter, this.queryParam)
        ).then(res => {
          return res.data
        })
      }
    }
  },
  methods: {
    alarmShow (timeScope) {
      this.visible = true
      this.queryParam.timeScope = timeScope
    },
    handleCancel () {
      this.visible = false
    },
    goToAdd () {
      this.$refs.WfudeviceAddOrUpdate.edit(null, 'add')
    },
    handleChange (info) {
      if (info.file.status !== 'uploading') {
        console.log(info.file, info.fileList)
      }
      if (info.file.status === 'done') {
        if (info.file.response.code === 0) {
          this.$message.success('导入成功！')
          this.init()
        } else if (info.file.response.code === 1) {
          this.$message.error(info.file.response.msg)
        }
        this.queryPage()
      } else if (info.file.status === 'error') {
        this.$message.error('导入失败，请重试！')
      }
    },
    show (record) {
      this.$refs.WfuAlarmDetail.show(record.userId)
    },
    update (record) {
      this.$refs.WfudeviceAddOrUpdate.edit(record.id, 'edit')
    },
    delete (record) {
      delObj(record.id)
      this.queryPage()
    }
  }
}
</script>

<style scoped>

</style>
